package com.tistory.devdiaries.controller;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.tistory.devdiaries.dto.Test;
import com.tistory.devdiaries.service.HelloService;

@Controller
public class HelloController {
	
	@Autowired
	private HelloService helloService;
	
	/*public void setHelloService(HelloService helloService) {
		this.helloService = helloService;
	}*/

	
	
	@RequestMapping(value="/hello.do")
	public ModelAndView hello() throws SQLException{
		
		ModelAndView modelAndView = new ModelAndView();
		
		List<Test> testList = helloService.getTestList();
		
		modelAndView.addObject("testList", testList);
		modelAndView.addObject("hello", "Hello Spring!");
		modelAndView.setViewName("hello");
		
		return modelAndView;
	}

	
}
